﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using DBUtility;
using CommonFunc;

public partial class Control_INewsList1 : System.Web.UI.UserControl
{
    MODEL.INewsClass MINC = new MODEL.INewsClass();
    MODEL.INewsClass _MINC = new MODEL.INewsClass();

    BLL.INewsClass BINC = new BLL.INewsClass();


    AutoPage AP = new AutoPage();

    protected void Page_Load(object sender, EventArgs e)
    {
        ControlDataInit();
    }


    #region ControlDataInit
    protected void ControlDataInit()
    {
        try
        {
            string SQLstr;

            if (Request.QueryString["ClassID"] == null)
            {
                SQLstr = "SELECT INews.*, INewsClass.INC_Title FROM (INews INNER JOIN INewsClass ON INews.IN_ClassID = INewsClass.INC_ID) ";
                SQLstr += "WHERE (INews.IN_IsLock = false) AND (INews.IN_IsDel = false) AND (INewsClass.INC_IsLock = false)";
            }
            else
            {
                MINC.INC_ID = Convert.ToInt32(Request.QueryString["ClassID"]);
                _MINC = BINC.GetDataByID(MINC);

                SQLstr = "SELECT * FROM INews ";
                SQLstr += " WHERE (INews.IN_IsLock = false) AND (INews.IN_IsDel = false) AND (INews.IN_ClassCode LIKE '" + _MINC.INC_ClassCode + "%') ";
            }

            DataTable DT_INewsList = AccHelper.GetDataTable(SQLstr);

            AP.AutoPageInit(DL_INewsList, DT_INewsList, 9, LBtn_FirstPage, LBtn_PrePage, LBtn_NextPage, LBtn_LastPage,
                LB_PageIndex, LB_PageCount);

            if (!IsPostBack)
            {
                AP.DLAutoPage(0);
            }
        }
        catch (Exception ex)
        {
            LB_INewsList1.Text = ex.Message;
        }
    }
    #endregion


    #region 产品图片 [格式化]
    protected string FormatImage(object _Image)
    {
        string ImageURL = Convert.ToString(_Image);

        if (ImageURL == "")
        {
            return "Manageweb/images/null.jpg";
        }
        else
        {
            return "UploadImage/" + ImageURL;
        }
    }
    #endregion
}
